package JDBC;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
/*
* 插入数据*/
public class Text02_Obj {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        Connection connection = DriverManager.getConnection(
                "jdbc:oracle:thin:@127.0.0.1:1521:orcl",
                "kz",
                "root"
        );
        Statement statement = connection.createStatement();
        String sql="insert into dept values(60,'财务部','上海虹桥')";
        int i = statement.executeUpdate(sql);
        System.out.println(i);//1
        if (i>0){
            System.out.println("新增成功");
        }
        else {
            System.out.println("新增失败");
        }
        statement.close();
        connection.createStatement();
    }
}
